<?php
//Kick Process
if (isset($_POST['kickchan']) && isset($_POST['kicknick'])) {
$controlmsg = new xmlrpcmsg('atheme.command');
				$controlmsg->addParam(new xmlrpcval($authcookie, $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval($uname, $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval(".", $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval("ChanServ", $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval("KICK", $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval($_POST['kickchan'], $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval($_POST['kicknick'], $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval($_POST['kickreason'], $xmlrpcString));
			$client = new xmlrpc_client(PATH, HOST, PORT);
			$controlresponse = $client->send($controlmsg);
			if($controlresponse->faultCode()) {
				printf('<h3>Fault</h3>');
				printf('Fault code: %d<br>', htmlentities($controlresponse->faultCode()));
				printf('Fault string: %s', htmlentities($controlresponse->faultString()));

				}else{ 
				echo $_POST['kicknick']." was successfully kicked from ".$_POST['kickchan']."."; }

				}
				
//Ban Process
if (isset($_POST['banchan']) && isset($_POST['bannick'])) {
$controlmsg = new xmlrpcmsg('atheme.command');
				$controlmsg->addParam(new xmlrpcval($authcookie, $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval($uname, $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval(".", $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval("ChanServ", $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval("BAN", $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval($_POST['banchan'], $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval($_POST['bannick'], $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval($_POST['banreason'], $xmlrpcString));
			$client = new xmlrpc_client(PATH, HOST, PORT);
			$controlresponse = $client->send($controlmsg);
			if($controlresponse->faultCode()) {
				printf('<h3>Fault</h3>');
				printf('Fault code: %d<br>', htmlentities($controlresponse->faultCode()));
				printf('Fault string: %s', htmlentities($controlresponse->faultString()));

				}else{ 
				echo $_POST['kicknick']." was successfully kicked from ".$_POST['kickchan']."."; }

				}
				
//Topic Process
if (isset($_POST['topicchan']) && isset($_POST['topic'])) {
$controlmsg = new xmlrpcmsg('atheme.command');
				$controlmsg->addParam(new xmlrpcval($authcookie, $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval($uname, $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval(".", $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval("ChanServ", $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval("TOPIC", $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval($_POST['topicchan'], $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval($_POST['topic'], $xmlrpcString));
			$client = new xmlrpc_client(PATH, HOST, PORT);
			$controlresponse = $client->send($controlmsg);
			if($controlresponse->faultCode()) {
				printf('<h3>Fault</h3>');
				printf('Fault code: %d<br>', htmlentities($controlresponse->faultCode()));
				printf('Fault string: %s', htmlentities($controlresponse->faultString()));

				}else{ 
				echo "The topic in ".$_POST['topicchan']." was successfully changed to \"".$_POST['topic']."\"."; }

				}	

//Info Process
if (isset($_POST['infochan'])) {
$controlmsg = new xmlrpcmsg('atheme.command');
				$controlmsg->addParam(new xmlrpcval($authcookie, $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval($uname, $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval(".", $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval("ChanServ", $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval("INFO", $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval($_POST['infochan'], $xmlrpcString));
			$client = new xmlrpc_client(PATH, HOST, PORT);
			$controlresponse = $client->send($controlmsg);
			if($controlresponse->faultCode()) {
				printf('<h3>Fault</h3>');
				printf('Fault code: %d<br>', htmlentities($controlresponse->faultCode()));
				printf('Fault string: %s', htmlentities($controlresponse->faultString()));

				}else{ 
				echo $controlresponse->serialize(); }

				}					
				
//Flag List Process
if (isset($_POST['flistchan'])) {
$controlmsg = new xmlrpcmsg('atheme.command');
				$controlmsg->addParam(new xmlrpcval($authcookie, $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval($uname, $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval(".", $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval("ChanServ", $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval("FLAGS", $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval($_POST['flistchan'], $xmlrpcString));
			$client = new xmlrpc_client(PATH, HOST, PORT);
			$controlresponse = $client->send($controlmsg);
			if($controlresponse->faultCode()) {
				printf('<h3>Fault</h3>');
				printf('Fault code: %d<br>', htmlentities($controlresponse->faultCode()));
				printf('Fault string: %s', htmlentities($controlresponse->faultString()));

				}else{ 
				echo $controlresponse->serialize(); }

				}						
				
				
//Flag Add/Modify Process
if (isset($_POST['faddchan'])) {
$controlmsg = new xmlrpcmsg('atheme.command');
				$controlmsg->addParam(new xmlrpcval($authcookie, $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval($uname, $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval(".", $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval("ChanServ", $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval("FLAGS", $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval($_POST['faddchan'], $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval($_POST['fnick'], $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval($_POST['fflags'], $xmlrpcString));
			$client = new xmlrpc_client(PATH, HOST, PORT);
			$controlresponse = $client->send($controlmsg);
			if($controlresponse->faultCode()) {
				printf('<h3>Fault</h3>');
				printf('Fault code: %d<br>', htmlentities($controlresponse->faultCode()));
				printf('Fault string: %s', htmlentities($controlresponse->faultString()));

				}else{ 
				echo $controlresponse->serialize(); }

				}						
								
				
					
											
				
				
?>
<?php if (isset($_POST['infochan']) || isset($_POST['flistchan']) || isset($_POST['rtfm'])){ echo "</pre>"; } ?>
<h1>ChanServ</h1>
<hr />
<a href="#" onclick="showhide('div1');"><h3>Topic</h3></a>
<div id="div1" style="display: none;">
<form method="post" action="<?php echo $PHP_SELF;?>"> 
Channel<br />
<input type="text" size="12" maxlength="15" name="topicchan"><br />
Topic<br />
<input type="text" size="12" maxlength="170" name="topic"><br />
<input type="submit" value="Set Topic!" name="submit">
</form>
</div>

<a href="#" onclick="showhide('div2');"><h3>Kick</h3></a>
<div id="div2" style="display: none;">
<form method="post" action="<?php echo $PHP_SELF;?>"> 
Channel<br />
<input type="text" size="12" maxlength="15" name="kickchan"><br />
Nick<br />
<input type="text" size="12" maxlength="15" name="kicknick"><br />
Reason<br />
<input type="text" size="12" maxlength="70" name="kickreason"><br />
<input type="submit" value="Kick!" name="submit">
</form>
</div>

<a href="#" onclick="showhide('div3');"><h3>Ban</h3></a>
<div id="div3" style="display: none;">
<form method="post" action="<?php echo $PHP_SELF;?>"> 
Channel<br />
<input type="text" size="12" maxlength="15" name="banchan"><br />
Nick or Hostname<br />
<input type="text" size="12" maxlength="15" name="bannick"><br />
Reason<br />
<input type="text" size="12" maxlength="70" name="banreason"><br />
<input type="submit" value="Ban!" name="submit">
</form>
</div>

<a href="#" onclick="showhide('div4');"><h3>Info</h3></a>
<div id="div4" style="display: none;">
<form method="post" action="<?php echo $PHP_SELF;?>"> 
Channel<br />
<input type="text" size="12" maxlength="15" name="infochan"><br />
<input type="submit" value="Get Info!" name="submit">
</form>
</div>

<a href="#" onclick="showhide('div5');"><h3>Flags</h3></a>
<div id="div5" style="display: none;">
<h4>List</h4>
<form method="post" action="<?php echo $PHP_SELF;?>"> 
Channel<br />
<input type="text" size="12" maxlength="15" name="flistchan"><br />
<input type="submit" value="Get List!" name="submit">
</form>

<h4>Add or Modify</h4>
<form method="post" action="<?php echo $PHP_SELF;?>"> 
Channel<br />
<input type="text" size="12" maxlength="15" name="faddchan"><br />
Nick or Hostname<br />
<input type="text" size="12" maxlength="50" name="fnick"><br />
Flags<br />
<input type="text" size="12" maxlength="20" name="fflags"><br />
<input type="submit" value="Modify Flag!" name="submit">
</form>

</div>
